// 异步更新
var asyn = function(that, tip, param){
	layer.confirm(tip,{
		skin: 'layui-layer-molv',
		btn: ['确定','取消']
	},function(){
		$.post(ctx + "/news/" + that.attr("data-id") + "/asyn", param, function(data){
			if(data.result_code=='SUC'){
				window.location.reload();
			}else{
				layer.msg("操作失败，请刷新重试！");
			}
		})
	});
};

$(function(){
	
	// 停用
	$(".disable-link").click(function(){
		var that = $(this);
		asyn(that, '是否停用?请确定！', {status:0});
	});
	
	// 启用
	$(".enable-link").click(function(){
		var that = $(this);
		asyn(that, '是否启用?请确定！', {status:1});
	});
	
	var editor=null;

	KindEditor.ready(function(K) {
		editor = K.create('#context', {
			themeType : 'default',
			resizeMode : 1,
			allowImageUpload : true,
			uploadJson : ctx + '/kingEditor/upload',
			fileManagerJson : ctx + '/kingEditor/fileManager',
			allowFileManager : true,
			filterMode : true,
			afterBlur:function(){
				this.sync();
			}
		});
		editor.html($("#context").val());
	});
	
	$('.colorpicker').colorpicker();
});